1 <?
2 $path =
"../images/cat";
3 $pathdb =
"images/cat";
4 if
(isset($_POST['butSaveLoai'])) {
5     $parent = $_POST[
'txtParent'];
6     $order = $_POST[
'txtSortOrder'];
7     $style = $_POST[
'style'];
8     
if($order=='') $order=0;
9     
else $order = $_POST['txtSortOrder'];
10     $status=($_POST[
'chkShow']!=''?1:0);
11     $CategoryName= trim($_POST[
'txtName']);
12         $link= trim($_POST[
'link']);
13
14     $err=
"";
15      
16     
if ($err=='')
17     {
18         
if (!empty($_POST['id'])) {
19             $oldid = $_POST[
'id'];
20             $sql =
"update cat set name='".$CategoryName."', parent='".$parent."',link='".$link."', thutu='".$order."',style='".$style."', status=".$status." where id='".$oldid."'";
21         }
else {
22             $sql =
"insert into cat (name, parent,link, thutu,style, status) values ('".$CategoryName."','".$parent."','".$link."','".$order."','".$style."','".$status."')";
23         }
24         
if (mysql_query($sql,$con)) {
25             
if(empty($_POST['id'])) $oldid = mysql_insert_id();
26
27             $sqlUpdateField =
"";
28             
29             $extsmall=GetFileExtention($_FILES[
'txtImage']['name']);
30             
if (MakeUpload($_FILES['txtImage'],"$path/slider_home_s$oldid$extsmall"))
31             {
32                 @chmod(
"$path/slider_home_s$oldid$extsmall", 0777);
33                 $sqlUpdateField =
" image='$pathdb/slider_home_s$oldid$extsmall' ";
34             }
35             
if($sqlUpdateField)
36             {
37                 $sqlUpdate =
"update cat set $sqlUpdateField where id='".$oldid."'";
38                 mysql_query($sqlUpdate,$con);
39             }
40         }
41         
else {
42             $err =
"<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
43         }
44     }
45     
if ($err=='') echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
46     
else echo '<p align=center class="err" style="line-height: 150%">'.$err.'</p>';
47 }
48 ?>
49 <?
50     
if (isset($_GET['id'])) {
51         $oldid=$_GET[
'id'];
52         $sql =
"select * from cat where id='".$oldid."'";
53         
if ($result = mysql_query($sql,$con)) {
54             $row=mysql_fetch_array($result);
55             $CategoryName=$row[
'name'];
56             $image=$row[
'image'];
57             $parent=$row[
'parent'];
58                         $link=$row[
'link'];
59             $order=$row[
'thutu'];
60             $style=$row[
'style'];
61             $status=$row[
'status'];
62             $date=$row[
'date'];
63         }
64     }
65 ?>
66
67 <form method=
"POST" name="FormLoaiSP" enctype="multipart/form-data" action="index.php">
68 <input type=hidden name=
"act" value="category_m">
69 <input type=hidden name=
"oldid" value="<? echo $oldid; ?>">
70 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
71 <input type=hidden name=
"cat" value="<? echo $_REQUEST['cat']; ?>">
72 <input type=
"hidden" name="id" value="<? echo $_REQUEST['id']; ?>">
73 <table border=
"1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
74   <tr>
75     <td width=
"45%" align="center" class="title" height="20">Thêm m&#7899;i / C&#7853;p nh&#7853;t : Danh m&#7909;c s&#7843;n ph&#7849;m</td>
76   </tr>
77   <tr>
78     <td width=
"45%">
79     <table border=
"0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
80       <tr>
81         <td width=
"15%" class="smallfont">
82         <p align=
"right">Tên danh m&#7909;c</td>
83         <td width=
"1%" class="smallfont">
84         <font color=
"#FF0000">*</font></td>
85         <td width=
"83%" class="smallfont">
86         <INPUT
value="<? echo $CategoryName; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
87       </tr>
88       <tr>
89         <td width=
"15%" class="smallfont">
90         <p align=
"right">Icon</td>
91         <td width=
"1%" class="smallfont">
92         <font color=
"#FF0000">*</font></td>
93         <td width=
"83%" class="smallfont">
94         <INPUT
value="<? echo $style; ?>" TYPE="text" NAME="style" CLASS=textbox size="34"></td>
95       </tr>
96       
97        
98       <tr>
99         <td width=
"15%" class="smallfont">
100         <p align=
"right">Thu&#7897;c danh m&#7909;c</td>
101         <td width=
"1%" class="smallfont">
102         &nbsp;</td>
103         <td width=
"83%" class="smallfont">
104         <
select size="1" name="txtParent">
105 <?
106         echo
"<option value='17'>[Danh m&#7909;c g&#7889;c]</option>";
107         $cats=GetListCat(
17);
108         
foreach ($cats as $cat)
109         {
110             
if ($cat[0]==$parent)
111                 echo
"<option value=".$cat[0]." selected>".$cat[1]."</option>";
112             
else
113                 echo
"<option value=".$cat[0].">".$cat[1]."</option>";
114         }
115 ?>
116         </
select>
117         
118 </td>
119       </tr>
120       <tr>
121         <td width=
"15%" class="smallfont" align="right">
122         Không hi&#
7875;n th&#7883;</td>
123         <td width=
"1%" class="smallfont" align="right">
124         &nbsp;</td>
125         <td width=
"83%" class="smallfont">
126         <input type=
"checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
127       </tr>
128     
129       <tr>
130         <td width=
"15%" class="smallfont" align="right">
131         Th&#
7913; t&#7921; s&#7855;p x&#7871;p</td>
132         <td width=
"1%" class="smallfont" align="right">
133         &nbsp;</td>
134         <td width=
"83%" class="smallfont">
135         <INPUT
value="<? echo $order; ?>" TYPE="text" NAME="txtSortOrder" CLASS=textbox size="34"></td>
136       </tr>
137       <tr>
138         <td width=
"15%" class="smallfont">
139         <p align=
"right">
140         <INPUT TYPE=
"submit" NAME="butSaveLoai" VALUE="C&#7853;p nh&#7853;t" CLASS=button>&nbsp;</td>
141         <td width=
"1%" class="smallfont">
142         &nbsp;</td>
143         <td width=
"83%" class="smallfont"><p align="left">&nbsp;<INPUT TYPE="reset" CLASS=button value="Nh&#7853;p l&#7841;i"></td>
144       </tr>
145     </table>
146     </td>
147   </tr>
148   </table>
149 </form>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.984 lượt xem

Gõ tìm kiếm nhanh...